import { defineStore } from 'pinia'

export const globalDataFromParentStore = defineStore('globalDataFromParentStore', {
  state: () => ({
    info: {},
    changeInfo: {},
  }),
  getters: {
    getInfo() {
      return this.info
    },
    getInfoByKey(state) {
      return (key) => {
        return state.info[key]
      }
    },
    getChangeInfo() {
      return this.changeInfo
    },
    getChangeInfoByKey(state) {
      return (key) => {
        return state.changeInfo[key]
      }
    },
  },
  actions: {
    setInfo(info) {
      this.info = info
    },
    setChangeInfo(info) {
      this.changeInfo = { ...this.changeInfo, ...info }
    },
  },
})
